﻿package com.tz.listener;

import com.tz.AppConfig;
import com.tz.util.AcUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Created by Administrator on 2016/7/28.
 */
//@WebListener
public class MyContextLoaderListener implements ServletContextListener {
    public void contextInitialized(ServletContextEvent event) {
        System.out.println("项目启动了...");
        ServletContext application = event.getServletContext();
        ApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class);
        application.setAttribute("ac",ac);
    }

    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
